public class Test {
    public static void main(String[] args) {
        int[]  arr = {2,3,4,5,18,17,6};
        maxArea(arr);
    }

    /**
     * 盛水最多的容器
     */
    public static int maxArea(int[] height) {
        int s = 0;
        int n = height.length;
        int left = 0,right = n-1;
        while(left < right) {
            int h = Math.min(height[left],height[right]);
            s = Math.max( h * (right-left),s);
            if(height[left] > height[right]) {
                right--;
            }else {
                left++;
            }
        }
        return s;
    }
    //无重复字符的子字串

    public int lengthOfLongestSubstring(String s) {
        int len = 0;
        int n = s.length();
        for(int left =0,right=0;right<n;right++) {
            int cur = left;
            //去重
            while(cur < right) {
                if(s.charAt(cur) == s.charAt(right)) {
                    left = ++cur;
                    break;
                }
                cur++;
            }
            //没有重复之后更新结果
            len = Math.max(len,(right-left+1));
        }
        return len;
    }

}
